home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / unixcpio.gz / unixnet.cpio / arp.h < prev    next >
C/C++ Source or Header  |  1994-07-11  |  3KB  |  83 lines

  1. /* Size of ARP hash table */
  2. #define    ARPSIZE    17
  3.  
  4. /* Lifetime of a valid ARP entry */
  5. #define    ARPLIFE        900    /* 15 minutes */
  6. /* Lifetime of a pending ARP entry */
  7. #define    PENDTIME    30    /* 30 seconds */
  8.  
  9. /* ARP definitions (see RFC 826) */
  10.  
  11. /* Address size definitions */
  12. #define    IPALEN    4        /* Length in bytes of an IP address */
  13. #define    MAXHWALEN    255    /* Maximum length of a hardware address */
  14.  
  15. /* ARP opcodes */
  16. #define    ARP_REQUEST    1
  17. #define    ARP_REPLY    2
  18.  
  19. /* Hardware types */
  20. #define    ARP_NETROM    0    /* Fake for NET/ROM (never actually sent) */
  21. #define    ARP_ETHER    1    /* Assigned to 10 megabit Ethernet */
  22. #define    ARP_EETHER    2    /* Assigned to experimental Ethernet */
  23. #define    ARP_AX25    3    /* Assigned to AX.25 Level 2 */
  24. #define    ARP_PRONET    4    /* Assigned to PROnet token ring */
  25. #define    ARP_CHAOS    5    /* Assigned to Chaosnet */
  26. #define    ARP_ARCNET    7
  27. #define    ARP_APPLETALK    8
  28. extern char *arptypes[];    /* Type fields in ASCII, defined in arpcmd */
  29. #define    NHWTYPES 9
  30.  
  31. /* Table of hardware types known to ARP */
  32. struct arp_type {
  33.     int16 hwalen;        /* Hardware length */
  34.     int16 iptype;        /* Hardware type field for IP */
  35.     int16 arptype;        /* Hardware type field for ARP */
  36.     char *bdcst;        /* Hardware broadcast address */
  37.     int (*format)();    /* Function that formats addresses */
  38.     int (*scan)();        /* Reverse of format */
  39. };
  40. extern struct arp_type arp_type[];
  41. #define    NULLATYPE    (struct arp_type *)0
  42.  
  43. /* Format of an ARP request or reply packet. From p. 3 */
  44. struct arp {
  45.     int16 hardware;            /* Hardware type */
  46.     int16 protocol;            /* Protocol type */
  47.     char hwalen;            /* Hardware address length, bytes */
  48.     char pralen;            /* Length of protocol address */
  49.     int16 opcode;            /* ARP opcode (request/reply) */
  50.     char shwaddr[MAXHWALEN];    /* Sender hardware address field */
  51.     int32 sprotaddr;        /* Sender Protocol address field */
  52.     char thwaddr[MAXHWALEN];    /* Target hardware address field */
  53.     int32 tprotaddr;        /* Target protocol address field */
  54. };
  55.         
  56. /* Format of ARP table */
  57. struct arp_tab {
  58.     struct arp_tab *next;    /* Doubly-linked list pointers */
  59.     struct arp_tab *prev;    
  60.     int32 ip_addr;        /* IP Address, host order */
  61.     int16 hardware;        /* Hardware type */
  62.     char *hw_addr;        /* Hardware address */
  63.     char state;        /* (In)complete */
  64. #define    ARP_PENDING    0
  65. #define    ARP_VALID    1
  66.     char pub;        /* Respond to requests for this entry? */
  67.     struct timer timer;    /* Time until aging this entry */
  68.     struct mbuf *pending;    /* Queue of datagrams awaiting resolution */
  69. };
  70. struct arp_tab *arp_lookup(),*arp_add();
  71. #define    NULLARP    (struct arp_tab *)0
  72. extern struct arp_tab *arp_tab[];
  73.  
  74. struct arp_stat {
  75.     unsigned recv;        /* Total number of ARP packets received */
  76.     unsigned badtype;    /* Incoming requests for unsupported hardware */
  77.     unsigned badlen;    /* Incoming length field(s) didn't match types */
  78.     unsigned badaddr;    /* Bogus incoming addresses */
  79.     unsigned inreq;        /* Incoming requests for us */
  80.     unsigned replies;    /* Replies sent */
  81.     unsigned outreq;    /* Outoging requests sent */
  82. };
  83.